package com.example.demo.controller;

import com.example.demo.base.*;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/zutnlp")
public class SentenceController {

    @ResponseBody
    @GetMapping(value="/segmentation")
    public Result<?> Segmentation(@RequestParam String sentence) {
        String str = sentence;
        Segmentation segmentation = new Segmentation(str);
        String str2 = segmentation.getSegtext();
        return Result.success(str2);
    }

    @ResponseBody
    @GetMapping(value="/senSplit")
    public Result<?> SenSplit(@RequestParam String sentence) {
        ArrayList<String> sensRes = new SenSplit(sentence).getSensRes();
        String str1 = "";
        for(String str:sensRes){
            str1 = str1 + "\n" + str;
        }
        return Result.success(str1);
    }

    @ResponseBody
    @GetMapping(value="/posTag")
    public Result<?> PosTag(@RequestParam String sentence) {
        String str = new PosTag(sentence).getPostext();
        return Result.success(str);
    }

    @ResponseBody
    @GetMapping(value="/namedEntity")
    public Result<?> NamedEntity(@RequestParam String sentence) {
        String str = sentence;
        String str2 = new NamedEntity(str).getNertext();
        return Result.success(str2);
    }

    @ResponseBody
    @GetMapping(value="/spTree1")
    public Result<?> SPTree1(@RequestParam String sentence) {
        SPTree spTree = new SPTree(sentence);
        String str = spTree.getPrasetext();
        return Result.success(str);
    }

    @ResponseBody
    @GetMapping(value="/spTree2")
    public Result<?> SPTree2(@RequestParam String sentence) {
        SPTree spTree = new SPTree(sentence);
        String str = spTree.getDepprasetext();
        return Result.success(str);
    }


}
